<?php

namespace app\backend\controller;

use think\Controller;
use think\Request;
use think\facade\Env;
use app\common\model\Money;
use app\common\model\WalletLog;
use app\common\model\User as userModel;
use app\common\model\Banner as bannerModel;
use app\common\model\Config as configModel;
use app\backend\model\AdminUser as adminuserModel;
use app\common\model\Sendmsg as SendmsgModel;
use app\common\model\Area as AreaModel;
use app\common\model\Assets as AssetsModel;
use think\Validate;
use think\Db;


class Index extends Controller
{

   

    public function main()
    {
        $date= strtotime(date('Y-m-d'),time());
        $result= userModel::where('create_time','>=', $date )->select();
        $num=count($result);
        $total_number= userModel::field('id')->select();
        $total_number=count($total_number);
        $wallet_num=  Money::sum('balance');
        $integral_num=  Money::sum('integral');
        $sameday_money=WalletLog::where('create_time','>=', $date )->whereIn('type','4,6,7,8,9')->sum('money');
        $total_money=WalletLog::whereIn('type','4,6,7,8,9')->sum('money');

        $wallet=  Money::order('balance', 'desc')->limit(30)->select();
        //GMOD前100名
        $integral= Money::order('integral', 'desc')->limit(30)->select();

        
        $this->assign('wallet',$wallet);
        $this->assign('integral',$integral);

        return $this->fetch('',['num' => $num,'total_number' => $total_number,'wallet_num' =>$wallet_num,'integral_num' =>$integral_num,'sameday_money' => $sameday_money,'total_money' => $total_money]);
    }
    
}
